# koroFileHeader at Yungoal acer
# Create: 2021-07-22 16:55:37
# LastEdit: 2021-07-23 13:41:39
"""说明暂无"""
__author__ = '749B'


import unittest
from unittest.mock import patch

if __name__ == '__main__':
    import os
    import sys
    sys.path.append(os.getcwd())

from msrestazure.azure_cloud import AZURE_CHINA_CLOUD
# pylint: disable = import-error
from azure_client.client import Azure_Client, Azure_Resource_Graph_Client


class ResourceGraphClientTestCase(unittest.TestCase):

    def setUp(self):
        patcher = patch('azure_client.client.Azure_Resource_Graph_Client.resource_graph_query')
        self.addCleanup(patcher.stop)
        self.mock_method = patcher.start()

        if Azure_Client._instance is None:
            self.client = Azure_Client(AZURE_CHINA_CLOUD)
        else:
            self.client = Azure_Client(AZURE_CHINA_CLOUD)
            self.client.resource_graph_query = Azure_Resource_Graph_Client.resource_graph_query
        
    def test_resource_graph_query(self):
        self.assertIs(self.client.resource_graph_client.resource_graph_query, self.mock_method)
        self.assertIs(self.client.resource_graph_query, self.mock_method)
        self.assertEqual(self.client.resource_graph_query(), self.client.resource_graph_client.resource_graph_query())

    def test_resource_graph_query_default(self):
        self.client.resource_graph_query_default('', [])
        self.mock_method.assert_called_once_with(
            {"result_format": "objectArray"}, 
            {"subscriptions": [], "query": ''}, 
            {})


if __name__ == '__main__':
    unittest.main()

